/* 
This do file assigns the calculated state-level subsidies to each zip code.

NOTES:

*/

clear all

*change "mainpath" below to your folder location
global mainpath `"Z:/user/rih4/Solar Siting"'

*shouldn't need to change these paths if your folders are named the same
cd `"${mainpath}/JAERE Code Repository"'
global data_path `"Data JAERE"'
global data_intermediate `"${data_path}/intermediate_output"'
global data_final `"${data_path}/final_output"'
global scripts_subsidies `"Scripts - Subsidies"'


import excel `"${scripts_subsidies}/Solar_Incentives_Data_no_severin_data.xlsx"', sheet("Table2") cellrange(A1:B50) firstrow case(lower)
rename state STATE
rename npvwnetmeteringskwh state_subsidy_kwh
save `"${data_intermediate}/state_subsidy_kwh"', replace

clear all
import delimited `"${data_path}/zip_state.csv"', case(preserve)

merge m:1 STATE using `"${data_intermediate}/state_subsidy_kwh"'
drop _merge
rename state_subsidy_kwh subsidy_kwh
drop STATE
save `"${data_intermediate}/zip_subsidies"', replace
export delimited using `"${data_intermediate}/zip_subsidies.csv"', replace
